🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@turf/boolean-within

Package Overview
Dependencies
Maintainers
6
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/boolean-within

turf boolean-within module

6.5.0
Source
npm
Version published
Weekly downloads
538K
-23.96%
Maintainers
6
Weekly downloads
 
Created

What is @turf/boolean-within?

@turf/boolean-within is a module from the Turf.js library that provides geospatial analysis tools. This specific module is used to determine if a given geometry (point, line, polygon) is within another geometry. It is useful for spatial queries and geographic information system (GIS) applications.

What are @turf/boolean-within's main functionalities?

Point within Polygon

This feature checks if a point is within a polygon. The code sample creates a point and a polygon, then uses the booleanWithin function to determine if the point is inside the polygon.

const turf = require('@turf/turf');
const point = turf.point([2, 2]);
const polygon = turf.polygon([[
  [0, 0], [0, 5], [5, 5], [5, 0], [0, 0]
]]);
const isWithin = turf.booleanWithin(point, polygon);
console.log(isWithin); // true

LineString within Polygon

This feature checks if a LineString is within a polygon. The code sample creates a LineString and a polygon, then uses the booleanWithin function to determine if the LineString is inside the polygon.

const turf = require('@turf/turf');
const line = turf.lineString([[1, 1], [2, 2], [3, 3]]);
const polygon = turf.polygon([[
  [0, 0], [0, 5], [5, 5], [5, 0], [0, 0]
]]);
const isWithin = turf.booleanWithin(line, polygon);
console.log(isWithin); // true

Polygon within Polygon

This feature checks if a polygon is within another polygon. The code sample creates an inner polygon and an outer polygon, then uses the booleanWithin function to determine if the inner polygon is inside the outer polygon.

const turf = require('@turf/turf');
const innerPolygon = turf.polygon([[
  [1, 1], [1, 4], [4, 4], [4, 1], [1, 1]
]]);
const outerPolygon = turf.polygon([[
  [0, 0], [0, 5], [5, 5], [5, 0], [0, 0]
]]);
const isWithin = turf.booleanWithin(innerPolygon, outerPolygon);
console.log(isWithin); // true

Other packages similar to @turf/boolean-within

Keywords

turf

FAQs

Package last updated on 10 Jul 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts